#include <linux/init.h>
#include <linux/module.h>

MODULE_LICENSE("Dual BSD/GPL");

static inline int wait_a_minute(void *data)
{       
        schedule_timeout(HZ / 20);
        return 0;
}

void wait_for_condition(char *desc)
{       
        set_current_state(TASK_INTERRUPTIBLE);
        wait_a_minute(NULL);
        printk(KERN_ERR "wait for condition: %.20s\n", desc);
        set_current_state(TASK_RUNNING);
}

void test_wait(void) {
	int i = 0;
	while (i++ < 10) {
		printk("i:%d\n", i);
		wait_for_condition("wait test");
	}
}

static __init int test_init(void)
{
	printk(KERN_ERR "test init \n");
	test_wait();
	return 0;
}

static __exit void test_exit(void)
{
	printk(KERN_ERR "test exit \n");
}

module_init(test_init);
module_exit(test_exit);

